package com.hnkywl.sts.action.report;

import com.hnkywl.sts.dao.report.XslrDao;
import com.hnkywl.sts.service.report.XslrService;
import com.hnkywl.sts.service.sys.YgService;
import com.hnkywl.sts.util.POIUtil;
import com.hnkywl.sts.util.StringFormat;
import net.ruixin.web.struts2.SimpleActionSupport;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.util.Region;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-6-14
 * Time: 下午4:48
 * To change this template use File | Settings | File Templates.
 */
@Namespace("/report/xslr")
public class XslrAction extends SimpleActionSupport {
    private Long gsId;
    private XslrService xslrService;
    private Date date;
    private Date xsrqStart;
    private Date xsrqEnd;
    private Long khId;
    private Long defaultJg;
    private String defaultJgMc;
    private Date currentTime = new Date();

    //查询范围 0 =全部  1=本公司  2 =本部门  3=本人
    private Integer cxfw;
    private Integer xslx;
    private Integer jszt;
//    private int page ;
//    private int rows  ;
//    private String name;
//    private String code;
//    private String ggxh;


    @Action("xslr")
    public String xslr() {
        date = new Date();
        currentTime = new Date();
        cxfw = YgService.getCurrentYgCxfw();
        //如果查询范围为全部不带入初始值，如果不是全部只能查询到本公司或本部门
        if (cxfw != 0) {
            defaultJg = YgService.getCurrentYgZgGsId() == 1 ?
                    YgService.getCurrentYgGsId() : YgService.getCurrentYgZgGsId();
            defaultJgMc = YgService.getCurrentYgZgGsId() == 1 ?
                    YgService.getCurrentYgGs() : YgService.getCurrentYgZgGs();
        }

        return SUCCESS;
    }

    @Action("xslrhz")
    public String xslrhz() {
        date = new Date();
        currentTime = new Date();
        cxfw = YgService.getCurrentYgCxfw();
        //如果查询范围为全部不带入初始值，如果不是全部只能查询到本公司或本部门
        if (cxfw != 0) {
            defaultJg = YgService.getCurrentYgZgGsId() == 1 ?
                    YgService.getCurrentYgGsId() : YgService.getCurrentYgZgGsId();
            defaultJgMc = YgService.getCurrentYgZgGsId() == 1 ?
                    YgService.getCurrentYgGs() : YgService.getCurrentYgZgGs();
        }

        return SUCCESS;
    }

    @Action("xslrList")
    public void xslrList() {
//        String start = year + "-" + months + "-" + "01";
//        Integer endmonths = (Integer.parseInt(months) + 1);
//        String end = year + "-" + endmonths.toString() + "-" + "01";
        String json = xslrService.xslrList(gsId, xsrqStart, xsrqEnd, khId, xslx, jszt);
        renderJson(json);
    }

    @Action("xslrhzList")
    public void xslrhzList() {
        String json = xslrService.xslrhzList(gsId, xsrqStart, xsrqEnd, xslx, jszt);
        renderJson(json);
    }

    //采购明细标签打印  (铁运入库标签)
    @Action("xslr_export")
    public String cgmxTagExport() {
//        String start = year + "-" + months + "-" + "01";
//        Integer endmonths = (Integer.parseInt(months) + 1);
//        String end = year + "-" + endmonths.toString() + "-" + "01";
        Map<String, List<Map>> xslrInfo = xslrDao.xslrList(gsId, xsrqStart, xsrqEnd, khId, xslx, jszt);
        HSSFWorkbook excel = new HSSFWorkbook();
        POIUtil poiUtil = new POIUtil(excel);
        HSSFCellStyle cellStyleCenter = poiUtil.createContent3HSSFCellStyle(excel);
        HSSFCellStyle cellStyleLeft = poiUtil.createContent4HSSFCellStyle(excel);
        HSSFCellStyle headerCelleStyle = poiUtil.createHeaderHSSFCellStyle(excel);
        HSSFCellStyle titleStyle = poiUtil.createTitleHSSFCellStyle(excel);
        HSSFSheet sheet = excel.createSheet();
        excel.setSheetName(0, "销售利润", HSSFWorkbook.ENCODING_UTF_16);
        sheet.setDefaultColumnWidth((short) 15);
        sheet.setColumnWidth((short) 0, (short) (3 * 512));
        sheet.setColumnWidth((short) 1, (short) (12 * 512));
        sheet.setColumnWidth((short) 2, (short) (12 * 512));
        sheet.setColumnWidth((short) 3, (short) (12 * 512));
        sheet.setColumnWidth((short) 4, (short) (6 * 512));
        sheet.setColumnWidth((short) 5, (short) (12 * 512));
        sheet.setColumnWidth((short) 6, (short) (12 * 512));
        sheet.setColumnWidth((short) 7, (short) (12 * 512));
        sheet.setColumnWidth((short) 8, (short) (6 * 512));
        sheet.setColumnWidth((short) 9, (short) (6 * 512));
        sheet.setColumnWidth((short) 10, (short) (6 * 512));
        sheet.setColumnWidth((short) 11, (short) (8 * 512));
        sheet.setColumnWidth((short) 12, (short) (8 * 512));
        sheet.setColumnWidth((short) 13, (short) (8 * 512));
        sheet.setColumnWidth((short) 14, (short) (8 * 512));
        sheet.setColumnWidth((short) 15, (short) (8 * 512));
        sheet.setColumnWidth((short) 16, (short) (8 * 512));
        sheet.setColumnWidth((short) 17, (short) (8 * 512));

        HSSFRow row0 = sheet.createRow((int) 0);
        row0.setHeightInPoints(36);
        HSSFCell titleCell = row0.createCell((short) 0);
        titleCell.setCellStyle(titleStyle);
        titleCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        titleCell.setCellValue("销售利润导出表");
        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 15));

        HSSFRow row1 = sheet.createRow((int) 1);
        row1.setHeightInPoints(21);
        HSSFCell xh = row1.createCell((short) 0);
        xh.setCellStyle(headerCelleStyle);
        xh.setEncoding(HSSFCell.ENCODING_UTF_16);
        xh.setCellValue("序号");
        HSSFCell gsmc = row1.createCell((short) 1);
        gsmc.setCellStyle(headerCelleStyle);
        gsmc.setEncoding(HSSFCell.ENCODING_UTF_16);
        gsmc.setCellValue("公司名称");
        HSSFCell bmmc = row1.createCell((short) 2);
        bmmc.setCellStyle(headerCelleStyle);
        bmmc.setEncoding(HSSFCell.ENCODING_UTF_16);
        bmmc.setCellValue("部门名称");
        HSSFCell xsdh = row1.createCell((short) 3);
        xsdh.setCellStyle(headerCelleStyle);
        xsdh.setEncoding(HSSFCell.ENCODING_UTF_16);
        xsdh.setCellValue("销售单号");
        HSSFCell cksj = row1.createCell((short) 4);
        cksj.setCellStyle(headerCelleStyle);
        cksj.setEncoding(HSSFCell.ENCODING_UTF_16);
        cksj.setCellValue("出库时间");
        HSSFCell khmc = row1.createCell((short) 5);
        khmc.setCellStyle(headerCelleStyle);
        khmc.setEncoding(HSSFCell.ENCODING_UTF_16);
        khmc.setCellValue("客户名称");
        HSSFCell mc = row1.createCell((short) 6);
        mc.setCellStyle(headerCelleStyle);
        mc.setEncoding(HSSFCell.ENCODING_UTF_16);
        mc.setCellValue("名称");
        HSSFCell gg = row1.createCell((short) 7);
        gg.setCellStyle(headerCelleStyle);
        gg.setEncoding(HSSFCell.ENCODING_UTF_16);
        gg.setCellValue("规格");
        HSSFCell dw = row1.createCell((short) 8);
        dw.setCellStyle(headerCelleStyle);
        dw.setEncoding(HSSFCell.ENCODING_UTF_16);
        dw.setCellValue("单位");
        HSSFCell th = row1.createCell((short) 9);
        th.setCellStyle(headerCelleStyle);
        th.setEncoding(HSSFCell.ENCODING_UTF_16);
        th.setCellValue("图号");
        HSSFCell cd = row1.createCell((short) 10);
        cd.setCellStyle(headerCelleStyle);
        cd.setEncoding(HSSFCell.ENCODING_UTF_16);
        cd.setCellValue("产地");
        HSSFCell sl = row1.createCell((short) 11);
        sl.setCellStyle(headerCelleStyle);
        sl.setEncoding(HSSFCell.ENCODING_UTF_16);
        sl.setCellValue("数量(元)");
        HSSFCell xsj = row1.createCell((short) 12);
        xsj.setCellStyle(headerCelleStyle);
        xsj.setEncoding(HSSFCell.ENCODING_UTF_16);
        xsj.setCellValue("销售价(元)");
        HSSFCell xse = row1.createCell((short) 13);
        xse.setCellStyle(headerCelleStyle);
        xse.setEncoding(HSSFCell.ENCODING_UTF_16);
        xse.setCellValue("销售额(元)");
        HSSFCell xscb = row1.createCell((short) 14);
        xscb.setCellStyle(headerCelleStyle);
        xscb.setEncoding(HSSFCell.ENCODING_UTF_16);
        xscb.setCellValue("销售成本(元)");
        HSSFCell xslr = row1.createCell((short) 15);
        xslr.setCellStyle(headerCelleStyle);
        xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
        xslr.setCellValue("销售利润(元)");
        HSSFCell jszt = row1.createCell((short) 16);
        jszt.setCellStyle(headerCelleStyle);
        jszt.setEncoding(HSSFCell.ENCODING_UTF_16);
        jszt.setCellValue("结算状态");
        HSSFCell jssj = row1.createCell((short) 17);
        jssj.setCellStyle(headerCelleStyle);
        jssj.setEncoding(HSSFCell.ENCODING_UTF_16);
        jssj.setCellValue("开票时间");

        int i = 2;
        for (; i < xslrInfo.get("rows").size() + 2; i++) {
            Map<String, Object> xslrRow = xslrInfo.get("rows").get(i - 2);
            HSSFRow row = sheet.createRow(i);
            row.setHeightInPoints(19);
            row = sheet.createRow(i);
            xh = row.createCell((short) 0);
            xh.setCellStyle(cellStyleCenter);
            xh.setEncoding(HSSFCell.ENCODING_UTF_16);
            xh.setCellValue(Integer.toString(i - 1));

            gsmc = row.createCell((short) 1);
            gsmc.setCellStyle(cellStyleCenter);
            gsmc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("GS")) {
                gsmc.setCellValue(xslrRow.get("GS").toString());
            }

            bmmc = row.createCell((short) 2);
            bmmc.setCellStyle(cellStyleCenter);
            bmmc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("BM")) {
                bmmc.setCellValue(xslrRow.get("BM").toString());
            }

            xsdh = row.createCell((short) 3);
            xsdh.setCellStyle(cellStyleCenter);
            xsdh.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSDH")) {
                xsdh.setCellValue(xslrRow.get("XSDH").toString());
            }


            cksj = row.createCell((short) 4);
            cksj.setCellStyle(cellStyleCenter);
            cksj.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("CKSJ")) {
                cksj.setCellValue(xslrRow.get("CKSJ").toString());
            }


            khmc = row.createCell((short) 5);
            khmc.setCellStyle(cellStyleCenter);
            khmc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("KH")) {
                khmc.setCellValue(xslrRow.get("KH").toString());
            }

            mc = row.createCell((short) 6);
            mc.setCellStyle(cellStyleCenter);
            mc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("GGMC")) {
                mc.setCellValue(xslrRow.get("GGMC").toString());
            }

            gg = row.createCell((short) 7);
            gg.setCellStyle(cellStyleCenter);
            gg.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("GG")) {
                gg.setCellValue(xslrRow.get("GG").toString());
            }

            dw = row.createCell((short) 8);
            dw.setCellStyle(cellStyleCenter);
            dw.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("DW")) {
                dw.setCellValue(xslrRow.get("DW").toString());
            }


            th = row.createCell((short) 9);
            th.setCellStyle(cellStyleCenter);
            th.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("TH")) {
                th.setCellValue(xslrRow.get("TH").toString());
            }


            cd = row.createCell((short) 10);
            cd.setCellStyle(cellStyleCenter);
            cd.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("CD")) {
                cd.setCellValue(xslrRow.get("CD").toString());
            }


            sl = row.createCell((short) 11);
            sl.setCellStyle(cellStyleCenter);
            sl.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("CKSL")) {
                sl.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                sl.setCellValue(((BigDecimal) xslrRow.get("CKSL")).doubleValue());
            }


            xsj = row.createCell((short) 12);
            xsj.setCellStyle(cellStyleCenter);
            xsj.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSJ")) {
                xsj.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xsj.setCellValue(((BigDecimal) xslrRow.get("XSJ")).doubleValue());
            }


            xse = row.createCell((short) 13);
            xse.setCellStyle(cellStyleCenter);
            xse.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSE")) {
                xse.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xse.setCellValue(((BigDecimal) xslrRow.get("XSE")).doubleValue());
            }


            xscb = row.createCell((short) 14);
            xscb.setCellStyle(cellStyleCenter);
            xscb.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSCB")) {
                xscb.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xscb.setCellValue(((BigDecimal) xslrRow.get("XSCB")).doubleValue());
            }

            xslr = row.createCell((short) 15);
            xslr.setCellStyle(cellStyleCenter);
            xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSLR")) {
                xslr.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xslr.setCellValue(((BigDecimal) xslrRow.get("XSLR")).doubleValue());
            }

            xslr = row.createCell((short) 16);
            xslr.setCellStyle(cellStyleCenter);
            xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("YJS")) {
                xslr.setCellValue(xslrRow.get("YJS").toString());
            }

            xslr = row.createCell((short) 17);
            xslr.setCellStyle(cellStyleCenter);
            xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("JSSJ")) {
                xslr.setCellValue(xslrRow.get("JSSJ").toString());
            }
        }

        HSSFRow rowFooter = sheet.createRow(i);
        rowFooter.setHeightInPoints(21);
        HSSFCell footerCell = rowFooter.createCell((short) 0);
        footerCell.setCellStyle(titleStyle);
        footerCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        Map<String, Object> xslrFooter = xslrInfo.get("footer").get(0);
        String footer = StringFormat.format("合计：销售额：{0}，销售成本：{1}，销售利润{2}", xslrFooter.get("XSE").toString()
                , xslrFooter.get("XSCB").toString(), xslrFooter.get("XSLR").toString());
        footerCell.setCellValue(footer);
        sheet.addMergedRegion(new Region(i, (short) 0, i, (short) 15));

        try {
            SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
            String filename = StringFormat.format("销售利润_{0}", dateformat.format(new Date()));
            response.setContentType("application/x-download");
            String filedisplay = new String((filename + ".xls").getBytes("gb2312"), "iso8859-1");
            response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
            excel.write(response.getOutputStream());
            response.getOutputStream().close();
        } catch (Exception e) {
            e.printStackTrace();
            renderText("位置异常，导出失败" + e.getMessage());
        }
        return null;
    }

    @Action("xslrhz_export")
    public String xslrHzExport() {
        Map<String, List<Map>> xslrhzInfo = xslrDao.xslrhzList(gsId, xsrqStart, xsrqEnd, xslx, jszt);
        HSSFWorkbook excel = new HSSFWorkbook();
        POIUtil poiUtil = new POIUtil(excel);
        HSSFCellStyle cellStyleCenter = poiUtil.createContent3HSSFCellStyle(excel);
        HSSFCellStyle cellStyleLeft = poiUtil.createContent4HSSFCellStyle(excel);
        HSSFCellStyle headerCelleStyle = poiUtil.createHeaderHSSFCellStyle(excel);
        HSSFCellStyle titleStyle = poiUtil.createTitleHSSFCellStyle(excel);
        HSSFSheet sheet = excel.createSheet();
        excel.setSheetName(0, "销售利润汇总", HSSFWorkbook.ENCODING_UTF_16);
        sheet.setDefaultColumnWidth((short) 15);
        sheet.setColumnWidth((short) 0, (short) (3 * 512));
        sheet.setColumnWidth((short) 1, (short) (12 * 512));
        sheet.setColumnWidth((short) 2, (short) (12 * 512));
        sheet.setColumnWidth((short) 3, (short) (12 * 512));
        sheet.setColumnWidth((short) 4, (short) (12 * 512));
        sheet.setColumnWidth((short) 5, (short) (12 * 512));

        HSSFRow row0 = sheet.createRow((int) 0);
        row0.setHeightInPoints(36);
        HSSFCell titleCell = row0.createCell((short) 0);
        titleCell.setCellStyle(titleStyle);
        titleCell.setEncoding(HSSFCell.ENCODING_UTF_16);
        titleCell.setCellValue("销售利润汇总导出表");
        sheet.addMergedRegion(new Region(0, (short) 0, 0, (short) 15));

        HSSFRow row1 = sheet.createRow((int) 1);
        row1.setHeightInPoints(21);
        HSSFCell xh = row1.createCell((short) 0);
        xh.setCellStyle(headerCelleStyle);
        xh.setEncoding(HSSFCell.ENCODING_UTF_16);
        xh.setCellValue("序号");
        HSSFCell gsmc = row1.createCell((short) 1);
        gsmc.setCellStyle(headerCelleStyle);
        gsmc.setEncoding(HSSFCell.ENCODING_UTF_16);
        gsmc.setCellValue("公司名称");
        HSSFCell bmmc = row1.createCell((short) 2);
        bmmc.setCellStyle(headerCelleStyle);
        bmmc.setEncoding(HSSFCell.ENCODING_UTF_16);
        bmmc.setCellValue("部门名称");
        HSSFCell xse = row1.createCell((short) 3);
        xse.setCellStyle(headerCelleStyle);
        xse.setEncoding(HSSFCell.ENCODING_UTF_16);
        xse.setCellValue("销售额(元)");
        HSSFCell xscb = row1.createCell((short) 4);
        xscb.setCellStyle(headerCelleStyle);
        xscb.setEncoding(HSSFCell.ENCODING_UTF_16);
        xscb.setCellValue("销售成本(元)");
        HSSFCell xslr = row1.createCell((short) 5);
        xslr.setCellStyle(headerCelleStyle);
        xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
        xslr.setCellValue("销售利润(元)");

        Double xsehj = 0d;
        Double xscbhj = 0d;
        Double xslrhj = 0d;

        int i = 2;
        for (; i < xslrhzInfo.get("rows").size() + 2; i++) {
            Map<String, Object> xslrRow = xslrhzInfo.get("rows").get(i - 2);
            HSSFRow row = sheet.createRow(i);
            row.setHeightInPoints(19);
            row = sheet.createRow(i);
            xh = row.createCell((short) 0);
            xh.setCellStyle(cellStyleCenter);
            xh.setEncoding(HSSFCell.ENCODING_UTF_16);
            xh.setCellValue(Integer.toString(i - 1));

            gsmc = row.createCell((short) 1);
            gsmc.setCellStyle(cellStyleCenter);
            gsmc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("GS")) {
                gsmc.setCellValue(xslrRow.get("GS").toString());
            }

            bmmc = row.createCell((short) 2);
            bmmc.setCellStyle(cellStyleCenter);
            bmmc.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("BM")) {
                bmmc.setCellValue(xslrRow.get("BM").toString());
            }

            xse = row.createCell((short) 3);
            xse.setCellStyle(cellStyleCenter);
            xse.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSE")) {
                xse.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xse.setCellValue(((BigDecimal) xslrRow.get("XSE")).doubleValue());
            }

            xscb = row.createCell((short) 4);
            xscb.setCellStyle(cellStyleCenter);
            xscb.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSCB")) {
                xscb.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xscb.setCellValue(((BigDecimal) xslrRow.get("XSCB")).doubleValue());
            }

            xslr = row.createCell((short) 5);
            xslr.setCellStyle(cellStyleCenter);
            xslr.setEncoding(HSSFCell.ENCODING_UTF_16);
            if (null != xslrRow.get("XSLR")) {
                xslr.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
                xslr.setCellValue(((BigDecimal) xslrRow.get("XSLR")).doubleValue());
            }
        }

        HSSFRow rowFooter = sheet.createRow(i);
        rowFooter.setHeightInPoints(21);
        HSSFCell footerCell = rowFooter.createCell((short) 0);
        footerCell.setCellStyle(titleStyle);
        footerCell.setEncoding(HSSFCell.ENCODING_UTF_16);
//        String footer = StringFormat.format("合计：销售额：{0}，销售成本：{1}，销售利润{2}", xsehj.toString()
//                , xscbhj.toString(), xscbhj.toString());
//        footerCell.setCellValue(footer);
        sheet.addMergedRegion(new Region(i, (short) 0, i, (short) 15));

        try {
            SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMdd");
            String filename = StringFormat.format("销售利润汇总_{0}", dateformat.format(new Date()));
            response.setContentType("application/x-download");
            String filedisplay = new String((filename + ".xls").getBytes("gb2312"), "iso8859-1");
            response.addHeader("Content-Disposition", "attachment;filename=" + filedisplay);
            excel.write(response.getOutputStream());
            response.getOutputStream().close();
        } catch (Exception e) {
            e.printStackTrace();
            renderText("位置异常，导出失败" + e.getMessage());
        }
        return null;
    }

    private static int getMonthDay(String year, String month) {
        int result = 0;
        switch (Integer.parseInt(month)) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                result = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                result = 30;
                break;
            case 2:
                result = 28;
                if (Integer.parseInt(year) % 400 == 0 || (Integer.parseInt(year) % 4 == 0 && Integer.parseInt(year) % 100 != 0)) {
                    result = 29;
                }
                break;
        }

        return result;
    }

    //=================setter getter==============
    public Long getGsId() {
        return gsId;
    }

    public void setGsId(Long gsId) {
        this.gsId = gsId;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Date getXsrqStart() {
        return xsrqStart;
    }

    public void setXsrqStart(Date xsrqStart) {
        this.xsrqStart = xsrqStart;
    }

    public Date getXsrqEnd() {
        return xsrqEnd;
    }

    public void setXsrqEnd(Date xsrqEnd) {
        this.xsrqEnd = xsrqEnd;
    }

    public Date getCurrentTime() {
        return currentTime;
    }

    public void setCurrentTime(Date currentTime) {
        this.currentTime = currentTime;
    }

    public Long getKhId() {
        return khId;
    }

    public void setKhId(Long khId) {
        this.khId = khId;
    }

    public Long getDefaultJg() {
        return defaultJg;
    }

    public void setDefaultJg(Long defaultJg) {
        this.defaultJg = defaultJg;
    }

    public Integer getCxfw() {
        return cxfw;
    }

    public void setCxfw(Integer cxfw) {
        this.cxfw = cxfw;
    }

    public String getDefaultJgMc() {
        return defaultJgMc;
    }

    public void setDefaultJgMc(String defaultJgMc) {
        this.defaultJgMc = defaultJgMc;
    }

    public Integer getXslx() {
        return xslx;
    }

    public void setXslx(Integer xslx) {
        this.xslx = xslx;
    }

    public Integer getJszt() {
        return jszt;
    }

    public void setJszt(Integer jszt) {
        this.jszt = jszt;
    }

    //=================setter===================
    @Autowired
    public void setXslrService(XslrService xslrService) {
        this.xslrService = xslrService;
    }

    private XslrDao xslrDao;

    @Autowired
    public void setXslrDao(XslrDao xslrDao) {
        this.xslrDao = xslrDao;
    }
}
